package com.da.javatest.niuke.other;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * @author JokerDa.
 * @date 2021/12/17 15:47
 * Description:https://www.nowcoder.com/practice/389fc1c3d3be4479a154f63f495abff8?
 * tpId=188&&tqId=38602&rp=1&ru=/activity/oj&qru=/ta/job-code-high-week/question-ranking
 */
public class NC75Solution {
    public int[] FindNumsAppearOnce(int[] array) {
        Set<Integer> set = new HashSet<>();
        for (int i : array) {
            if (set.contains(i)) {
                set.remove(i);
            } else {
                set.add(i);
            }
        }
        return set.stream().mapToInt(Integer::valueOf).toArray();
    }

    public static void main(String[] args) {
        NC75Solution test = new NC75Solution();
        System.out.println(Arrays.toString(test.FindNumsAppearOnce(new int[] {1, 2, 3, 3, 2, 9})));
    }
}
